/**
 * Created by judasnow on 21/06/2017.
 */

import Cookies from 'universal-cookie';
import { AUTH_COOKIE_NAME } from '../config'


const cookies = new Cookies();

export function saveCookie(name, value, opt) {
    var _opt = Object.assign(opt, {path: '/'})
    if (value) {
        cookies.set(name, value, _opt)
    } else {

    }
}

export function getCookie(name) {
    return cookies.get(name, undefined)
}

export function deleteCookie(name) {
    cookies.remove(name, { path: '/' })
}

export function doLogout() {
    deleteCookie(AUTH_COOKIE_NAME)
}